package models

import (
	"time"

	"gorm.io/gorm"
)

type ItemType string

const (
	TypeTask        ItemType = "task"
	TypeIssue       ItemType = "issue"
	TypeRequirement ItemType = "requirement"
)

type ItemStatus string

const (
	StatusPending    ItemStatus = "pending"
	StatusInProgress ItemStatus = "in_progress"
	StatusCompleted  ItemStatus = "completed"
	StatusClosed     ItemStatus = "closed"
)

type ItemPriority string

const (
	PriorityLow    ItemPriority = "low"
	PriorityMedium ItemPriority = "medium"
	PriorityHigh   ItemPriority = "high"
	PriorityUrgent ItemPriority = "urgent"
)

type Item struct {
	ID          uint           `json:"id" gorm:"primaryKey"`
	Title       string         `json:"title" gorm:"not null"`
	Description string         `json:"description"`
	Type        ItemType       `json:"type" gorm:"not null"`
	Status      ItemStatus     `json:"status" gorm:"default:'pending'"`
	Priority    ItemPriority   `json:"priority" gorm:"default:'medium'"`
	ProjectID   uint           `json:"project_id"`
	Project     Project        `json:"project" gorm:"foreignKey:ProjectID"`
	ReporterID  uint           `json:"reporter_id"`
	Reporter    User           `json:"reporter" gorm:"foreignKey:ReporterID"`
	AssigneeID  *uint          `json:"assignee_id"`
	Assignee    *User          `json:"assignee" gorm:"foreignKey:AssigneeID"`
	Pictures    []Picture      `json:"pictures" gorm:"foreignKey:ItemID"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`
}
